import axios from 'axios'
import { getToken, setToken, removeToken } from '@/utils/auth'
import store from '@/store'

axios.interceptors.request.use(
  config => {
    if (store.getters.token) { // 判断是否存在token，如果存在的话，则每个http header都加上token
      config.headers.token = getToken()
    }
    return config
  },
  err => {
    return Promise.reject(err)
  })

export function fetch(query) {
  return axios.get(`${process.env.BASE_API}/admin/user/user/fetchOne/userId/${query}`)
}

export function fetchList(query) {
  return axios.post(`${process.env.BASE_API}/admin/user/user/index`, query)
}

export function updateUserType(query) {
  return axios.post(`${process.env.BASE_API}/admin/user/user/updateUserType`, query)
}

